Pearson Edexcel · GCSE · Computer Science

    Course version: 1CP2 · Version from Sept 2020

    Be able to determine the correct output of an algorithm for a given set of…

    Full specification wording

    Algorithms: 1.2.4 be able to determine the correct output of an algorithm for a given set of data and use a trace table to determine what value a variable will hold at a given point in an algorithm

    To find an algorithm's output you execute it exactly as written with the supplied data.

    Checked against the Pearson Edexcel 1CP2 specification (opens in a new tab) on .

    • Point 2 of 4
    • 4 key terms

    Study notes

    From the checked teaching notes for this specification point.

    The idea

    To find an algorithm's output you execute it exactly as written with the supplied data. Work through each statement in order, updating every variable as its value changes, and respect sequence, selection and iteration. A trace table records this process: one column per variable, one row per step, so you can read off the value a variable holds at any chosen point. For example, given total ← 0 then a loop that adds 4 three times, the trace shows total becoming 4, then 8, then 12, so the output is 12. When a condition is tested, record the Boolean result and follow only the branch it selects. When a loop repeats, keep adding rows until the loop condition fails. The final row gives the output; an intermediate row gives the value at that point.

    What earns the marks

    • Execute statements in the order written, updating each variable as its value changes.
    • Record one column per variable and one row per step in the trace table.
    • Evaluate conditions correctly and follow only the branch selected by the Boolean result.
    • Repeat loop rows until the loop condition becomes false, then stop.
    • Read the final row to determine the algorithm's output.
    • Read the row at the specified point to determine the value a variable holds there.
    • Substitute the given data accurately so arithmetic and comparisons use the supplied values.

    Common mistakes and how to put them right

    • Skipping loop iterations: every repetition needs its own trace row, so a loop that runs three times produces three rows.

    • Updating a variable before evaluating the condition that uses its old value.

      Put it right: Evaluate the condition with the current value, then update.

    • Ignoring the branch not taken.

      Put it right: Only the statements inside the selected branch are executed, so the other branch must not change any variable.

    • Reading the wrong row.

      Put it right: The output comes from the final row, while an intermediate value comes from the row at the stated point.

    Exam tips

    • Draw the trace table before starting and label every column with a variable name.
    • Write the Boolean result of each condition in the row so the chosen branch is clear.
    • After the last row, state the output explicitly and check it against the algorithm's purpose.

    Try the lesson

    The start of the Algorithms: 1.2.4 be able to determine the correct output of an algorithm for a given set of data and use a trace table to determine what value a variable will hold at a given point in an algorithm lesson, made from checked teaching notes for this specification point.

    Have a go first

    Consider this algorithm. total = 0 FOR i = 1 TO 4 total = total + i NEXT i OUTPUT total What value is output?

    Listen

    To find an algorithm's output you execute it exactly as written with the supplied data. Work through each statement in order, updating every variable as its value changes, and respect sequence, selection and iteration. A trace table records this process: one column per variable, one row per step, so you can read off the value a variable holds at any chosen point. For example, given total ← 0 then a loop that adds 4 three times, the trace shows total becoming 4, then 8, then 12, so the output is 12. When a condition is tested, record the Boolean result and follow only the branch it selects. When a loop repeats, keep adding rows until the loop condition fails. The final row gives the output; an intermediate row gives the value at that point. A strong answer earns marks for these points. Execute statements in the order written, updating each variable as its value changes. Record one column per variable and one row per step in the trace table. Evaluate conditions correctly and follow only the branch selected by the Boolean result. Repeat loop rows until the loop condition becomes false, then stop. Exam tip: Draw the trace table before starting and label every column with a variable name.

    See it

    A flowchart that begins at a start node labelled 'Start: total ← 0'. An arrow leads to a process node 'Add 4 to total', then to 'Record new total in trace row', then to a decision node 'Loop condition fails?'. From the decision, a branch labelled 'No' loops back up to 'Add 4 to total', and a branch labelled 'Yes' leads to an end node 'Stop: final row gives output'.
    Shows the loop that adds 4 to total repeatedly, recording each new total in a trace row until the loop condition fails, when the final row gives the output.

    Key words

    Say what each word means before you turn the card.

    Trace table

    Try answering aloud or in your head before turning the card.

    Step-by-step execution of algorithms

    Try answering aloud or in your head before turning the card.

    Variable values at a given point

    Try answering aloud or in your head before turning the card.

    Determining correct output from given data

    Try answering aloud or in your head before turning the card.

    See every definition
    Trace table
    A recording tool with one column per variable and one row per step, so you can read off the value a variable holds at any chosen point.
    Step-by-step execution of algorithms
    Working through each statement in order, updating every variable as its value changes, and respecting sequence, selection and iteration.
    Variable values at a given point
    The value read from the row at the specified point in a trace table, rather than from the final row.
    Determining correct output from given data
    Executing the algorithm exactly as written with the supplied data, then reading the final row to determine the output.

    There is more to this lesson

    The full lesson goes on to check your understanding and help you earn the marks. Create a free account to carry on, with your progress saved.

    Carry on with the full lesson

    A week of Premium from your first lesson · Then the free plan continues · No card, no charge

    Test your understanding of Algorithms: 1.2.4 be able to determine the correct output of an algorithm for a given set of data and use a trace table to determine what value a variable will hold at a given point in an algorithm

    Active recall beats re-reading. Take an instant quiz now to test what you’ve learned and lock it into long-term memory.

    Take topic quiz

    A week of Premium from your first lesson · Then the free plan continues · No card, no charge